preexperiment_date <- "18 June 2023 10 03AM/All"
postexperiment_date <- "18 June 2023 03 13PM/All"
##--- last fish run in trial ---##
experiment_date <- "18 June 2023 11 41AM/Oxygen"
experiment_date2 <- "18 June 2023 11 41AM/All"
firesting <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1 <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_date2,"slopes/Cycle_22.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) preexperiment_date_asus <- "19 June 2023 10 56AM/All"
postexperiment_date_asus <- "19 June 2023 05 00PM/All"
##--- last fish run in trial ---##
experiment_date_asus <- "19 June 2023 01 47PM/Oxygen"
experiment_date2_asus <- "19 June 2023 01 47PM/All"
firesting_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19)
Cycle_1_asus <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE)
Cycle_last_asus <-read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_date2_asus,"slopes/Cycle_21.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) chamber1_dell = 0.04650
chamber2_dell = 0.04593
chamber3_dell = 0.04977
chamber4_dell = 0.04860
chamber1_asus = 0.04565
chamber2_asus = 0.04573
chamber3_asus = 0.04551
chamber4_asus = 0.04791
Date_tested="2023-06-18"
Clutch = "124"
Male = "CSUD312"
Female = "CSUD304"
Population = "Sudbury reef"
Tank =167
salinity = 36
Date_analysed = Sys.Date() Replicate = 1
mass = 0.0007281
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_dell
system1 = "Dell_7440"
Notes="Second cycle used for max"
##--- time of trail ---##
experiment_mmr_date <- "18 June 2023 11 21AM/Oxygen"
experiment_mmr_date2 <- "18 June 2023 11 21AM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0005010464
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 1.980022e-05
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 5.94
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 22 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 16 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 1 1 270.1115 -0.02851847 0.977 NA 46 301 6012.44
## 2: 2 1 270.3834 -0.02627573 0.985 NA 586 841 6552.44
## 3: 3 1 299.0425 -0.02829665 0.976 NA 1126 1381 7092.44
## 4: 8 1 377.8359 -0.02860924 0.992 NA 3826 4081 9792.44
## 5: 12 1 440.5816 -0.02864119 0.981 NA 5986 6241 11952.44
## 6: 14 1 466.3856 -0.02831099 0.996 NA 7066 7321 13032.44
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6267.44 98.012 90.231 -0.02851847 0.0004937177 -0.02901218 -0.02901218
## 2: 6807.44 98.374 91.228 -0.02627573 0.0004713515 -0.02674708 -0.02674708
## 3: 7347.44 98.410 91.578 -0.02829665 0.0004489853 -0.02874563 -0.02874563
## 4: 10047.45 97.456 89.979 -0.02860924 0.0003371541 -0.02894640 -0.02894640
## 5: 12207.44 97.726 90.151 -0.02864119 0.0002476895 -0.02888888 -0.02888888
## 6: 13287.44 97.652 90.452 -0.02831099 0.0002029571 -0.02851395 -0.02851395
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0486 0.0007281 NA 36 30 1.013253 -0.3139464
## 2: %Air sec 0.0486 0.0007281 NA 36 30 1.013253 -0.2894353
## 3: %Air sec 0.0486 0.0007281 NA 36 30 1.013253 -0.3110620
## 4: %Air sec 0.0486 0.0007281 NA 36 30 1.013253 -0.3132345
## 5: %Air sec 0.0486 0.0007281 NA 36 30 1.013253 -0.3126121
## 6: %Air sec 0.0486 0.0007281 NA 36 30 1.013253 -0.3085549
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -431.1858 NA mgO2/hr/kg -431.1858
## 2: -397.5213 NA mgO2/hr/kg -397.5213
## 3: -427.2243 NA mgO2/hr/kg -427.2243
## 4: -430.2081 NA mgO2/hr/kg -430.2081
## 5: -429.3532 NA mgO2/hr/kg -429.3532
## 6: -423.7810 NA mgO2/hr/kg -423.7810
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 1 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0007281 | ch4 | Dell_7440 | 0.0486 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 428.3505 | 0.311882 | 0.9844 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 1.25
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 4 6 8 9 11 12 14 15 17 18 20 21 22 25 26 32 33 41
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.20
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 523.8192 -0.087704201 0.9793130 NA 178 239 4931.45
## 2: NA 2 523.1830 -0.087578783 0.9788178 NA 177 238 4930.45
## 3: NA 3 521.0067 -0.087129403 0.9770963 NA 181 242 4934.45
## 4: NA 4 520.1695 -0.086967197 0.9786099 NA 179 240 4932.44
## 5: NA 5 519.8935 -0.086921085 0.9761895 NA 175 236 4928.45
## ---
## 236: NA 236 120.4399 -0.005263595 0.5724804 NA 8 69 4761.44
## 237: NA 237 120.1760 -0.005210050 0.5769099 NA 9 70 4762.44
## 238: NA 238 119.9093 -0.005155803 0.5809182 NA 10 71 4763.44
## 239: NA 239 119.8734 -0.005150008 0.5824108 NA 12 73 4765.44
## 240: NA 240 119.7946 -0.005133013 0.5819455 NA 11 72 4764.44
## endtime oxy endoxy rate
## 1: 4991.45 90.924 86.423 -0.087704201
## 2: 4990.45 90.857 86.494 -0.087578783
## 3: 4994.45 90.771 86.286 -0.087129403
## 4: 4992.44 90.847 86.426 -0.086967197
## 5: 4988.45 91.163 86.465 -0.086921085
## ---
## 236: 4821.44 95.618 94.954 -0.005263595
## 237: 4822.44 95.613 94.847 -0.005210050
## 238: 4823.44 95.581 94.855 -0.005155803
## 239: 4825.44 95.412 94.939 -0.005150008
## 240: 4824.44 95.520 94.874 -0.005133013
##
## Regressions : 240 | Results : 240 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 240 adjusted rate(s):
## Rate : -0.0877042
## Adjustment : 0.0005010464
## Adjusted Rate : -0.08820525
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 41 rate(s) removed, 199 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 198 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time endtime
## 1: NA 1 523.8192 -0.0877042 0.979313 NA 178 239 4931.45 4991.45
## oxy endoxy rate adjustment rate.adjusted rate.input oxy.unit
## 1: 90.924 86.423 -0.0877042 0.0005010464 -0.08820525 -0.08820525 %Air
## time.unit volume mass area S t P rate.abs rate.m.spec
## 1: sec 0.0486 0.0007281 NA 36 30 1.013253 -0.9544859 -1310.927
## rate.a.spec output.unit rate.output
## 1: NA mgO2/hr/kg -1310.927
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 1 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0007281 | ch4 | Dell_7440 | 0.0486 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 428.3505 | 0.311882 | 0.9844 | 1310.927 | 0.9544859 | 0.979313 | 882.5765 | 0.6426039 | Second cycle used for max |
## Rows: 25 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 2
mass = 0.0008265
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber3_dell
system1 = "Dell_7440"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "18 June 2023 11 41AM/Oxygen"
experiment_mmr_date2 <- "18 June 2023 11 41AM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0005478875
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0006372256
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 5.94
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 22 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 16 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 8 1 367.1066 -0.02734233 0.988 NA 3826 4081 9792.44
## 2: 10 1 394.9285 -0.02714934 0.984 NA 4906 5161 10872.44
## 3: 13 1 425.5253 -0.02614420 0.996 NA 6526 6781 12492.45
## 4: 14 1 454.0938 -0.02722685 0.990 NA 7066 7321 13032.44
## 5: 20 1 540.3910 -0.02709448 0.987 NA 10306 10561 16272.45
## 6: 21 1 553.1994 -0.02701525 0.977 NA 10846 11101 16812.45
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10047.45 98.912 91.930 -0.02734233 0.0001442876 -0.02748661 -0.02748661
## 2: 11127.44 99.193 92.346 -0.02714934 0.0000341304 -0.02718347 -0.02718347
## 3: 12747.44 98.573 92.090 -0.02614420 -0.0001311066 -0.02601310 -0.02601310
## 4: 13287.44 98.756 92.018 -0.02722685 -0.0001861850 -0.02704066 -0.02704066
## 5: 16527.44 98.962 92.153 -0.02709448 -0.0005166585 -0.02657782 -0.02657782
## 6: 17067.45 98.457 91.563 -0.02701525 -0.0005717379 -0.02644351 -0.02644351
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.3045985
## 2: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.3012391
## 3: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.2882694
## 4: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.2996566
## 5: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.2945274
## 6: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.2930391
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -368.5402 NA mgO2/hr/kg -368.5402
## 2: -364.4757 NA mgO2/hr/kg -364.4757
## 3: -348.7833 NA mgO2/hr/kg -348.7833
## 4: -362.5609 NA mgO2/hr/kg -362.5609
## 5: -356.3550 NA mgO2/hr/kg -356.3550
## 6: -354.5543 NA mgO2/hr/kg -354.5543
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 2 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0008265 | ch3 | Dell_7440 | 0.04977 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 361.2972 | 0.2986121 | 0.9852 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.13
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 527.0411 -0.07159387 0.9983855 NA 120 180 6086.45
## 2: NA 2 526.5770 -0.07151787 0.9984380 NA 121 181 6087.44
## 3: NA 3 526.3324 -0.07147565 0.9979736 NA 136 196 6102.45
## 4: NA 4 526.0628 -0.07143344 0.9982630 NA 122 182 6088.45
## 5: NA 5 525.9595 -0.07141460 0.9979335 NA 137 197 6103.45
## ---
## 236: NA 236 402.9570 -0.05111567 0.9928370 NA 10 70 5976.44
## 237: NA 237 402.7516 -0.05108366 0.9927983 NA 15 75 5981.44
## 238: NA 238 402.6320 -0.05106373 0.9924325 NA 14 74 5980.45
## 239: NA 239 402.5267 -0.05104390 0.9924952 NA 9 69 5975.45
## 240: NA 240 402.2211 -0.05099386 0.9925621 NA 11 71 5977.45
## endtime oxy endoxy rate
## 1: 6146.45 91.187 87.009 -0.07159387
## 2: 6147.44 91.184 86.970 -0.07151787
## 3: 6162.45 90.097 85.932 -0.07147565
## 4: 6148.45 91.130 86.954 -0.07143344
## 5: 6163.45 90.057 85.862 -0.07141460
## ---
## 236: 6036.44 97.533 94.358 -0.05111567
## 237: 6041.44 97.221 94.121 -0.05108366
## 238: 6040.45 97.332 94.130 -0.05106373
## 239: 6035.45 97.606 94.478 -0.05104390
## 240: 6037.45 97.509 94.257 -0.05099386
##
## Regressions : 240 | Results : 240 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 240 adjusted rate(s):
## Rate : -0.07159387
## Adjustment : 0.0005478875
## Adjusted Rate : -0.07214176
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 240 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 239 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 527.0411 -0.07159387 0.9983855 NA 120 180 6086.45
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6146.45 91.187 87.009 -0.07159387 0.0005478875 -0.07214176 -0.07214176
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04977 0.0008265 NA 36 30 1.013253 -0.7994535
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -967.2759 NA mgO2/hr/kg -967.2759
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 2 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0008265 | ch3 | Dell_7440 | 0.04977 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 361.2972 | 0.2986121 | 0.9852 | 967.2759 | 0.7994535 | 0.9983855 | 605.9787 | 0.5008414 |
## Rows: 26 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 3
mass = 0.0006752
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber2_dell
system1 = "Dell_7440"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "18 June 2023 11 41AM/Oxygen"
experiment_mmr_date2 <- "18 June 2023 11 41AM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0002263472
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0005673121
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 5.94
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 22 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 16 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 10 1 416.8885 -0.02935725 0.991 NA 4906 5161 10872.44
## 2: 13 1 481.6104 -0.03066718 0.983 NA 6526 6781 12492.45
## 3: 15 1 513.1804 -0.03062751 0.980 NA 7606 7861 13572.45
## 4: 17 1 540.6319 -0.03020593 0.980 NA 8686 8941 14652.45
## 5: 20 1 556.9240 -0.02820977 0.992 NA 10306 10561 16272.45
## 6: 21 1 611.2142 -0.03052399 0.996 NA 10846 11101 16812.45
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 11127.44 97.565 89.850 -0.02935725 -0.0001177111 -0.02923953 -0.02923953
## 2: 12747.44 98.140 90.884 -0.03066718 -0.0002283689 -0.03043881 -0.03043881
## 3: 13827.45 97.613 89.210 -0.03062751 -0.0003021408 -0.03032537 -0.03032537
## 4: 14907.44 97.756 90.162 -0.03020593 -0.0003759120 -0.02983002 -0.02983002
## 5: 16527.44 97.506 90.718 -0.02820977 -0.0004865694 -0.02772321 -0.02772321
## 6: 17067.45 97.875 90.323 -0.03052399 -0.0005234555 -0.03000053 -0.03000053
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.2990238
## 2: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.3112885
## 3: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.3101283
## 4: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.3050625
## 5: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.2835168
## 6: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.3068063
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -442.8670 NA mgO2/hr/kg -442.8670
## 2: -461.0315 NA mgO2/hr/kg -461.0315
## 3: -459.3132 NA mgO2/hr/kg -459.3132
## 4: -451.8106 NA mgO2/hr/kg -451.8106
## 5: -419.9004 NA mgO2/hr/kg -419.9004
## 6: -454.3932 NA mgO2/hr/kg -454.3932
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 3 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006752 | ch2 | Dell_7440 | 0.04593 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 453.8831 | 0.3064619 | 0.986 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.13
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 481.4073 -0.06452047 0.9829901 NA 1 61 5967.45
## 2: NA 2 478.0062 -0.06395248 0.9820173 NA 2 62 5968.45
## 3: NA 3 475.3864 -0.06348993 0.9875878 NA 60 120 6026.44
## 4: NA 4 475.2582 -0.06346906 0.9875981 NA 61 121 6027.44
## 5: NA 5 474.6067 -0.06336129 0.9874943 NA 59 119 6025.44
## ---
## 236: NA 236 365.4692 -0.04561313 0.9840196 NA 236 296 6202.44
## 237: NA 237 364.8566 -0.04551250 0.9829712 NA 239 299 6205.45
## 238: NA 238 364.6392 -0.04547866 0.9837078 NA 238 298 6204.44
## 239: NA 239 364.1224 -0.04539656 0.9832563 NA 237 297 6203.44
## 240: NA 240 363.4176 -0.04528137 0.9831228 NA 240 300 6206.44
## endtime oxy endoxy rate
## 1: 6027.45 96.540 92.831 -0.06452047
## 2: 6028.45 96.545 92.807 -0.06395248
## 3: 6086.44 92.828 88.942 -0.06348993
## 4: 6087.44 92.831 88.846 -0.06346906
## 5: 6085.44 92.768 88.902 -0.06336129
## ---
## 236: 6262.44 82.530 79.972 -0.04561313
## 237: 6265.45 82.415 79.882 -0.04551250
## 238: 6264.44 82.284 79.870 -0.04547866
## 239: 6263.44 82.330 79.938 -0.04539656
## 240: 6266.44 82.544 79.801 -0.04528137
##
## Regressions : 240 | Results : 240 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 240 adjusted rate(s):
## Rate : -0.06452047
## Adjustment : 0.0002263472
## Adjusted Rate : -0.06474681
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 240 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 239 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 481.4073 -0.06452047 0.9829901 NA 1 61 5967.45
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6027.45 96.54 92.831 -0.06452047 0.0002263472 -0.06474681 -0.06474681
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04593 0.0006752 NA 36 30 1.013253 -0.6621459
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -980.6663 NA mgO2/hr/kg -980.6663
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 3 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006752 | ch2 | Dell_7440 | 0.04593 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 453.8831 | 0.3064619 | 0.986 | 980.6663 | 0.6621459 | 0.9829901 | 526.7832 | 0.355684 |
## Rows: 27 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 4
mass = 0.0006247
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber1_dell
system1 = "Dell_7440"
Notes=""
##--- time of trail ---##
experiment_mmr_date <- "18 June 2023 11 41AM/Oxygen"
experiment_mmr_date2 <- "18 June 2023 11 41AM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",experiment_mmr_date2,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",preexperiment_date,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0008861206
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Dell7440/Experiment_",postexperiment_date,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.001148214
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2$TIME ==Cycle_1$Time[1], firesting$TIME)
Tstart.dTIME=as.numeric(firesting2[Tstart.row, "dTIME"])
Tend.row=which(firesting2$TIME ==tail(Cycle_last$Time, n=1), firesting$TIME)
Tend.dTIME=as.numeric(firesting2[Tend.row, "dTIME"])
apoly_insp <- firesting2 |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 5.94
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from selected replicates...
## To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: background rates in 'by' and 'by2' differ in sign (i.e. one is +ve, one is -ve).
## Ensure this is correct. The 'linear' adjustment has been performed regardless.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 2 rate(s) removed, 20 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 14 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 8 1 365.8630 -0.02714561 0.990 NA 3826 4081 9792.44
## 2: 9 1 352.1335 -0.02440713 0.993 NA 4366 4621 10332.44
## 3: 10 1 405.2258 -0.02806524 0.994 NA 4906 5161 10872.44
## 4: 12 1 441.4283 -0.02856840 0.973 NA 5986 6241 11952.44
## 5: 13 1 456.7686 -0.02852567 0.989 NA 6526 6781 12492.45
## 6: 20 1 550.5042 -0.02766576 0.982 NA 10306 10561 16272.45
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 10047.45 99.576 92.986 -0.02714561 1.933114e-04 -0.02733892 -0.02733892
## 2: 10587.44 99.640 93.416 -0.02440713 9.876532e-05 -0.02450589 -0.02450589
## 3: 11127.44 99.702 92.876 -0.02806524 4.218394e-06 -0.02806945 -0.02806945
## 4: 12207.44 99.488 92.691 -0.02856840 -1.848755e-04 -0.02838353 -0.02838353
## 5: 12747.44 99.827 92.666 -0.02852567 -2.794233e-04 -0.02824625 -0.02824625
## 6: 16527.44 99.794 92.387 -0.02766576 -9.412518e-04 -0.02672450 -0.02672450
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.2830565
## 2: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.2537245
## 3: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.2906202
## 4: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.2938720
## 5: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.2924506
## 6: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.2766951
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -453.1079 NA mgO2/hr/kg -453.1079
## 2: -406.1541 NA mgO2/hr/kg -406.1541
## 3: -465.2156 NA mgO2/hr/kg -465.2156
## 4: -470.4210 NA mgO2/hr/kg -470.4210
## 5: -468.1457 NA mgO2/hr/kg -468.1457
## 6: -442.9247 NA mgO2/hr/kg -442.9247
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 4 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006247 | ch1 | Dell_7440 | 0.0465 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 459.963 | 0.2873389 | 0.9856 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 5 6 7 9 10 14 15 16 17 18 19 22 24 25 29 30 31
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.94 5.94
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 24 25 28 31 32 34 36 38 39 40 43 44 45 47 48 49
## Minimum and Maximum intervals in uneven Time data:
## [1] 0.95 1.13
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 409.1610 -0.05178725 0.9949656 NA 9 69 5975.45
## 2: NA 2 408.6744 -0.05170438 0.9945846 NA 11 71 5977.45
## 3: NA 3 407.8147 -0.05156273 0.9947966 NA 10 70 5976.44
## 4: NA 4 407.5098 -0.05151321 0.9938013 NA 8 68 5974.49
## 5: NA 5 406.6833 -0.05137242 0.9939658 NA 12 72 5978.44
## ---
## 236: NA 236 340.6127 -0.04048360 0.9961884 NA 138 198 6104.45
## 237: NA 237 341.0383 -0.04047823 0.9977355 NA 47 107 6013.44
## 238: NA 238 340.1245 -0.04040227 0.9963559 NA 134 194 6100.47
## 239: NA 239 339.4812 -0.04029706 0.9965611 NA 133 193 6099.45
## 240: NA 240 339.4408 -0.04029015 0.9965758 NA 132 192 6098.45
## endtime oxy endoxy rate
## 1: 6035.45 99.457 96.684 -0.05178725
## 2: 6037.45 99.494 96.731 -0.05170438
## 3: 6036.44 99.467 96.692 -0.05156273
## 4: 6034.49 99.464 96.711 -0.05151321
## 5: 6038.44 99.511 96.670 -0.05137242
## ---
## 236: 6164.45 93.589 90.982 -0.04048360
## 237: 6073.44 97.659 95.160 -0.04047823
## 238: 6160.47 93.673 91.146 -0.04040227
## 239: 6159.45 93.747 91.216 -0.04029706
## 240: 6158.45 93.864 91.276 -0.04029015
##
## Regressions : 240 | Results : 240 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 240 adjusted rate(s):
## Rate : -0.05178725
## Adjustment : 0.0008861206
## Adjusted Rate : -0.05267337
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 240 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 239 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 409.161 -0.05178725 0.9949656 NA 9 69 5975.45
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6035.45 99.457 96.684 -0.05178725 0.0008861206 -0.05267337 -0.05267337
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.0465 0.0006247 NA 36 30 1.013253 -0.5453595
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -872.9942 NA mgO2/hr/kg -872.9942
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 4 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006247 | ch1 | Dell_7440 | 0.0465 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 459.963 | 0.2873389 | 0.9856 | 872.9942 | 0.5453595 | 0.9949656 | 413.0312 | 0.2580206 |
## Rows: 28 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 5
mass = 0.0006148
chamber = "ch4"
Swim = "good/good"
chamber_vol = chamber4_asus
system1 = "Asus"
Notes=""
##--- time of trail ---##
experiment_mmr_date_asus <- "18 June 2023 12 08PM/Oxygen"
experiment_mmr_date2_asus <- "18 June 2023 12 08PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.00144726
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.002300273
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=255,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 12 1 552.7107 -0.02775450 0.995 NA 4364 4553 16404.73
## 2: 17 1 616.7011 -0.02719800 0.993 NA 6360 6549 19104.11
## 3: 18 1 588.8649 -0.02502168 0.997 NA 6759 6948 19643.65
## 4: 19 1 601.2967 -0.02497538 0.985 NA 7158 7346 20184.10
## 5: 20 1 666.1096 -0.02743399 0.994 NA 7557 7746 20724.16
## 6: 21 1 660.9098 -0.02653130 0.978 NA 7957 8146 21264.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 16660.41 97.389 90.132 -0.02775450 0.002382440 -0.03013694 -0.03013694
## 2: 19359.70 97.036 90.117 -0.02719800 0.002665137 -0.02986314 -0.02986314
## 3: 19899.57 97.147 90.679 -0.02502168 0.002721660 -0.02774334 -0.02774334
## 4: 20438.82 97.310 90.616 -0.02497538 0.002778197 -0.02775358 -0.02775358
## 5: 20979.97 97.447 90.469 -0.02743399 0.002834814 -0.03026880 -0.03026880
## 6: 21519.77 96.277 89.165 -0.02653130 0.002891377 -0.02942267 -0.02942267
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.3214876
## 2: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.3185667
## 3: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.2959536
## 4: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.2960629
## 5: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.3228942
## 6: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.3138681
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -522.9141 NA mgO2/hr/kg -522.9141
## 2: -518.1632 NA mgO2/hr/kg -518.1632
## 3: -481.3820 NA mgO2/hr/kg -481.3820
## 4: -481.5596 NA mgO2/hr/kg -481.5596
## 5: -525.2020 NA mgO2/hr/kg -525.2020
## 6: -510.5206 NA mgO2/hr/kg -510.5206
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 5 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006148 | ch4 | Asus | 0.04791 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 511.6719 | 0.3145759 | 0.989 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.50
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch4
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.42
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 622.0024 -0.07587912 0.9906994 NA 49 94 6906.91
## 2: NA 2 621.9391 -0.07587121 0.9906826 NA 48 93 6905.57
## 3: NA 3 621.2164 -0.07576825 0.9904329 NA 47 92 6904.22
## 4: NA 4 620.2827 -0.07562980 0.9899978 NA 50 95 6908.25
## 5: NA 5 618.5898 -0.07539019 0.9898369 NA 46 91 6902.86
## ---
## 175: NA 175 195.8866 -0.01417516 0.8810239 NA 5 50 6847.63
## 176: NA 176 192.8425 -0.01373130 0.8972252 NA 4 49 6846.30
## 177: NA 177 192.2164 -0.01363647 0.9002463 NA 1 46 6842.23
## 178: NA 178 191.2414 -0.01349715 0.9077814 NA 3 48 6844.96
## 179: NA 179 190.2178 -0.01334703 0.9145299 NA 2 47 6843.58
## endtime oxy endoxy rate
## 1: 6966.91 97.764 93.542 -0.07587912
## 2: 6965.57 97.828 93.621 -0.07587121
## 3: 6964.22 97.933 93.584 -0.07576825
## 4: 6968.25 97.690 93.549 -0.07562980
## 5: 6962.86 97.997 93.685 -0.07539019
## ---
## 175: 6907.63 98.917 97.690 -0.01417516
## 176: 6906.30 98.993 97.764 -0.01373130
## 177: 6902.23 99.246 97.997 -0.01363647
## 178: 6904.96 99.021 97.828 -0.01349715
## 179: 6903.58 99.171 97.933 -0.01334703
##
## Regressions : 179 | Results : 179 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 179 adjusted rate(s):
## Rate : -0.07587912
## Adjustment : 0.00144726
## Adjusted Rate : -0.07732638
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 99 rate(s) removed, 80 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 79 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 622.0024 -0.07587912 0.9906994 NA 49 94 6906.91
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 6966.91 97.764 93.542 -0.07587912 0.00144726 -0.07732638 -0.07732638
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04791 0.0006148 NA 36 30 1.013253 -0.8248837
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1341.711 NA mgO2/hr/kg -1341.711
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 5 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006148 | ch4 | Asus | 0.04791 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 511.6719 | 0.3145759 | 0.989 | 1341.711 | 0.8248837 | 0.9906994 | 830.0386 | 0.5103078 | ||
| ### Expor | ting data |
## Rows: 29 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 6
mass = 0.0006241
chamber = "ch3"
Swim = "good/good"
chamber_vol = chamber1_asus
system1 = "Asus"
Notes="Chamber1 was mistakenly in position of chamber3"
##--- time of trail ---##
experiment_mmr_date_asus <- "18 June 2023 12 18PM/Oxygen"
experiment_mmr_date2_asus <- "18 June 2023 12 18PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0004210815
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0004860404
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 13 1 612.3943 -0.03035017 0.986 NA 4764 4946 16944.69
## 2: 14 1 590.5576 -0.02815916 0.984 NA 5163 5344 17484.23
## 3: 15 1 564.8555 -0.02588881 0.984 NA 5562 5743 18024.09
## 4: 18 1 644.8102 -0.02783161 0.978 NA 6759 6940 19643.65
## 5: 19 1 646.9606 -0.02718498 0.972 NA 7158 7339 20184.10
## 6: 21 1 645.6674 -0.02576650 0.971 NA 7957 8139 21264.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 17190.57 97.474 90.143 -0.03035017 0.0004965649 -0.03084673 -0.03084673
## 2: 17729.03 97.571 90.772 -0.02815916 0.0005008636 -0.02866002 -0.02866002
## 3: 18268.77 97.608 91.451 -0.02588881 0.0005051687 -0.02639398 -0.02639398
## 4: 19888.62 97.430 90.533 -0.02783161 0.0005180863 -0.02834970 -0.02834970
## 5: 20429.20 97.698 90.867 -0.02718498 0.0005223971 -0.02770737 -0.02770737
## 6: 21510.13 97.130 90.792 -0.02576650 0.0005310159 -0.02629752 -0.02629752
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.3135370
## 2: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.2913105
## 3: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.2682777
## 4: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.2881562
## 5: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.2816275
## 6: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.2672972
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -502.3826 NA mgO2/hr/kg -502.3826
## 2: -466.7689 NA mgO2/hr/kg -466.7689
## 3: -429.8633 NA mgO2/hr/kg -429.8633
## 4: -461.7148 NA mgO2/hr/kg -461.7148
## 5: -451.2537 NA mgO2/hr/kg -451.2537
## 6: -428.2922 NA mgO2/hr/kg -428.2922
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 6 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006241 | ch3 | Asus | 0.04565 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 462.3967 | 0.2885818 | 0.9808 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.53
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch3
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 3 4 5 6 9 10 11 12 14 15 16 17 19 20 21 23 24 25 26
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.53
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 786.4823 -0.09179290 0.9923984 NA 26 71 7498.75
## 2: NA 2 786.0283 -0.09173340 0.9923236 NA 25 70 7497.40
## 3: NA 3 784.2910 -0.09150110 0.9920600 NA 27 72 7500.09
## 4: NA 4 782.5895 -0.09127758 0.9916190 NA 24 69 7496.03
## 5: NA 5 779.5438 -0.09087033 0.9915962 NA 28 73 7501.42
## ---
## 174: NA 174 347.1900 -0.03388673 0.9692764 NA 116 161 7620.06
## 175: NA 175 346.7086 -0.03382397 0.9692623 NA 117 162 7621.40
## 176: NA 176 346.6614 -0.03381739 0.9692068 NA 114 159 7617.35
## 177: NA 177 346.6113 -0.03381078 0.9692003 NA 113 158 7616.02
## 178: NA 178 346.3622 -0.03377864 0.9691514 NA 118 163 7622.73
## endtime oxy endoxy rate
## 1: 7558.75 98.079 92.765 -0.09179290
## 2: 7557.40 98.059 92.838 -0.09173340
## 3: 7560.09 98.048 92.723 -0.09150110
## 4: 7556.03 98.182 92.917 -0.09127758
## 5: 7561.42 98.052 92.640 -0.09087033
## ---
## 174: 7680.06 89.022 86.922 -0.03388673
## 175: 7681.40 88.989 86.879 -0.03382397
## 176: 7677.35 89.093 87.023 -0.03381739
## 177: 7676.02 89.216 87.041 -0.03381078
## 178: 7682.73 88.898 86.871 -0.03377864
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.0917929
## Adjustment : 0.0004210815
## Adjusted Rate : -0.09221398
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 10 rate(s) removed, 168 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 167 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 786.4823 -0.0917929 0.9923984 NA 26 71 7498.75
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 7558.75 98.079 92.765 -0.0917929 0.0004210815 -0.09221398 -0.09221398
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04565 0.0006241 NA 36 30 1.013253 -0.9372952
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -1501.835 NA mgO2/hr/kg -1501.835
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 6 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0006241 | ch3 | Asus | 0.04565 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 462.3967 | 0.2885818 | 0.9808 | 1501.835 | 0.9372952 | 0.9923984 | 1039.438 | 0.6487134 | Chamber1 was mistakenly in position of chamber3 | |
| ### Expor | ting data |
## Rows: 30 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 7
mass = 0.0004735
chamber = "ch2"
Swim = "good/good"
chamber_vol = chamber3_asus
system1 = "Asus"
Notes="chamber3 was mistakenly in place of chamber2"
##--- time of trail ---##
experiment_mmr_date_asus <- "18 June 2023 12 28PM/Oxygen"
experiment_mmr_date2_asus <- "18 June 2023 12 28PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.001296905
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] 0.0009675921
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 11 1 627.6104 -0.03333083 0.991 NA 3965 4146 15864.44
## 2: 13 1 640.5500 -0.03199232 0.993 NA 4764 4946 16944.69
## 3: 14 1 679.5477 -0.03324291 0.999 NA 5163 5344 17484.23
## 4: 17 1 586.4709 -0.02555996 0.972 NA 6360 6541 19104.11
## 5: 18 1 755.3700 -0.03343103 0.993 NA 6759 6940 19643.65
## 6: 19 1 710.4145 -0.03033868 0.994 NA 7158 7339 20184.10
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 16109.20 98.354 90.252 -0.03333083 0.0009579363 -0.03428876 -0.03428876
## 2: 17190.57 98.612 90.614 -0.03199232 0.0009142377 -0.03290656 -0.03290656
## 3: 17729.03 98.482 90.213 -0.03324291 0.0008924453 -0.03413535 -0.03413535
## 4: 19348.94 97.574 91.114 -0.02555996 0.0008269508 -0.02638691 -0.02638691
## 5: 19888.62 98.406 90.503 -0.03343103 0.0008051337 -0.03423616 -0.03423616
## 6: 20429.20 98.125 90.693 -0.03033868 0.0007832800 -0.03112196 -0.03112196
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.3474541
## 2: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.3334480
## 3: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.3458996
## 4: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.2673833
## 5: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.3469211
## 6: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.3153644
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -733.7996 NA mgO2/hr/kg -733.7996
## 2: -704.2196 NA mgO2/hr/kg -704.2196
## 3: -730.5166 NA mgO2/hr/kg -730.5166
## 4: -564.6955 NA mgO2/hr/kg -564.6955
## 5: -732.6739 NA mgO2/hr/kg -732.6739
## 6: -666.0283 NA mgO2/hr/kg -666.0283
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 7 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0004735 | ch2 | Asus | 0.04551 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 713.4476 | 0.3378174 | 0.994 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 1.87
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch2
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 9 10 11 12 13 14 16 17 18 19 20 21 22 24
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.87
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 435.3962 -0.04121652 0.9901566 NA 129 174 8217.16
## 2: NA 2 435.3363 -0.04120958 0.9901369 NA 128 173 8215.82
## 3: NA 3 435.1812 -0.04119015 0.9900870 NA 130 175 8218.51
## 4: NA 4 434.9780 -0.04116700 0.9899617 NA 126 171 8213.10
## 5: NA 5 434.9309 -0.04116090 0.9899444 NA 127 172 8214.46
## ---
## 172: NA 172 229.9413 -0.01619106 0.9402171 NA 81 126 8152.07
## 173: NA 173 229.9647 -0.01619101 0.9375402 NA 77 122 8146.69
## 174: NA 174 228.1631 -0.01597144 0.9426953 NA 78 123 8148.05
## 175: NA 175 227.6860 -0.01591482 0.9451551 NA 80 125 8150.73
## 176: NA 176 226.9900 -0.01582894 0.9474507 NA 79 124 8149.40
## endtime oxy endoxy rate
## 1: 8277.16 96.694 94.296 -0.04121652
## 2: 8275.82 96.704 94.371 -0.04120958
## 3: 8278.51 96.651 94.249 -0.04119015
## 4: 8273.10 96.816 94.446 -0.04116700
## 5: 8274.46 96.788 94.417 -0.04116090
## ---
## 172: 8212.07 98.100 96.816 -0.01619106
## 173: 8206.69 98.171 97.028 -0.01619101
## 174: 8208.05 98.221 96.986 -0.01597144
## 175: 8210.73 98.202 96.855 -0.01591482
## 176: 8209.40 98.219 96.912 -0.01582894
##
## Regressions : 176 | Results : 176 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 176 adjusted rate(s):
## Rate : -0.04121652
## Adjustment : 0.001296905
## Adjusted Rate : -0.04251343
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 26 rate(s) removed, 150 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 149 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 435.3962 -0.04121652 0.9901566 NA 129 174 8217.16
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8277.16 96.694 94.296 -0.04121652 0.001296905 -0.04251343 -0.04251343
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04551 0.0004735 NA 36 30 1.013253 -0.4307961
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -909.8124 NA mgO2/hr/kg -909.8124
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 7 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0004735 | ch2 | Asus | 0.04551 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 713.4476 | 0.3378174 | 0.994 | 909.8124 | 0.4307961 | 0.9901566 | 196.3648 | 0.0929787 | chamber3 was mistakenly in place of chamber2 | |
| ### Expor | ting data |
## Rows: 31 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Replicate = 8
mass = 0.0007193
chamber = "ch1"
Swim = "good/good"
chamber_vol = chamber2_asus
system1 = "Asus"
Notes="Chamber2 was mistakenly in place of chamber1"
##--- time of trail ---##
experiment_mmr_date_asus <- "18 June 2023 12 37PM/Oxygen"
experiment_mmr_date2_asus <- "18 June 2023 12 37PM/All"
firesting_mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date_asus,"data raw/Firesting.txt"),
delim = "\t", escape_double = FALSE,
col_types = cols(`Time (HH:MM:SS)` = col_time(format = "%H:%M:%S"),
`Time (s)` = col_number(), Ch1...5 = col_number(),
Ch2...6 = col_number(), Ch3...7 = col_number(),
Ch4...8 = col_number()), trim_ws = TRUE,
skip = 19) ## New names:
## • `Ch1` -> `Ch1...5`
## • `Ch2` -> `Ch2...6`
## • `Ch3` -> `Ch3...7`
## • `Ch4` -> `Ch4...8`
## • `Ch 1` -> `Ch 1...9`
## • `Ch 2` -> `Ch 2...10`
## • `Ch 3` -> `Ch 3...11`
## • `Ch 4` -> `Ch 4...12`
## • `('C)` -> `('C)...15`
## • `('C)` -> `('C)...16`
## • `Ch 1` -> `Ch 1...18`
## • `Ch 2` -> `Ch 2...19`
## • `Ch 3` -> `Ch 3...20`
## • `Ch 4` -> `Ch 4...21`
## • `Ch1` -> `Ch1...22`
## • `Ch2` -> `Ch2...23`
## • `Ch3` -> `Ch3...24`
## • `Ch4` -> `Ch4...25`
## • `Ch1` -> `Ch1...26`
## • `Ch2` -> `Ch2...27`
## • `Ch3` -> `Ch3...28`
## • `Ch4` -> `Ch4...29`
## • `` -> `...31`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
Cycle_1.mmr <- read_delim(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",experiment_mmr_date2_asus,"slopes/Cycle_1.txt"),
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
`Seconds from start for linreg` = col_number(),
`ch1 po2` = col_number(), `ch2 po2` = col_number(),
`ch3 po2` = col_number(), `ch4 po2` = col_number(),
...8 = col_skip()), trim_ws = TRUE) ## New names:
## • `` -> `...8`
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",preexperiment_date_asus,"slopes"))
pre_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle2 <- read_delim("./Cycle_2.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
pre_cycle3 <- read_delim("./Cycle_3.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_pre1 <- pre_cycle1 %>% calc_rate.bg()##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0004814342
setwd(paste("C:/Users/jc527762/OneDrive - James Cook University/PhD dissertation/Data/2023/Resp_backup/2023_Resp/Asus/Experiment_",postexperiment_date_asus,"slopes"))
post_cycle1 <- read_delim("./Cycle_1.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle2 <- read_delim("./Cycle_4.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
post_cycle3 <- read_delim("./Cycle_5.txt",
delim = ";", escape_double = FALSE, col_types = cols(Time = col_time(format = "%H:%M:%S"),
...8 = col_skip()), trim_ws = TRUE) %>%
rename(dTIME = `Seconds from start for linreg`,
ch1 =`ch1 po2`,
ch2 =`ch2 po2`,
ch3 =`ch3 po2`,
ch4 =`ch4 po2`) %>%
select(c("Time",chamber))
bg_post1 <- post_cycle1 %>% calc_rate.bg() ##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
##
## # plot.calc_rate.bg # -------------------
## plot.calc_rate.bg: Plotting all 1 background rates ...
## -----------------------------------------
## [1] -0.0002168683
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
#### subset data
Tstart.row=which(firesting2_asus$TIME ==Cycle_1_asus$Time[1], firesting_asus$TIME)
Tstart.dTIME=as.numeric(firesting2_asus[Tstart.row, "dTIME"])
Tend.row=which(firesting2_asus$TIME ==tail(Cycle_last_asus$Time, n=1), firesting_asus$TIME)
Tend.dTIME=as.numeric(firesting2_asus[Tend.row, "dTIME"])
apoly_insp <- firesting2_asus |>
subset_data(from=Tstart.dTIME,
to=Tend.dTIME,
by="time")
apoly_insp <- inspect(apoly_insp, time=1, oxygen=2)##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.59
## -----------------------------------------
apoly_cr.int <- calc_rate.int(apoly_insp,
starts=(195+45+300),
wait=45,
measure=245,
by="time",
plot=TRUE) ##
## # plot.calc_rate.int # ------------------
## plot.calc_rate.int: Plotting rate from all replicates ...
## plot.calc_rate.int: Plotting first 20 selected reps only. To plot others modify 'pos' input.
## -----------------------------------------
apoly_cr.int_adj <- adjust_rate(apoly_cr.int,
by = bg_pre,
by2 = bg_post,
time_by = Tstart.row,
time_by2 = Tend.row,
method = "linear")## Warning: adjust_rate: One or more of the timestamps for the rate(s) in 'x' do not lie between the timestamps for the 'by' and 'by2' background rates.
## Ensure this is correct. The adjustment value has been calculated regardless by extrapolating outside the background rates time window.
## adjust_rate: Rate adjustments applied using "linear" method.
apoly_cr.int_adj2 <- apoly_cr.int_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253) ## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
ggplot(as.data.frame(apoly_cr.int_adj2$summary), aes(x=row, y=rate.output*-1)) +
geom_point() +
stat_smooth(method = "lm", formula = y~poly(x, 2), color="red") +
theme_classic()apoly_rmr <- apoly_cr.int_adj2 |>
select_rate(method ="rsq", n=c(0.95,1)) |>
select_rate(method="lowest", n=6) |>
plot(type="full") |>
summary(export = TRUE)## select_rate: Selecting rates with rsq values between 0.95 and 1...
## ----- Selection complete. 0 rate(s) removed, 21 rate(s) remaining -----
## select_rate: Selecting lowest 6 *absolute* rate values...
## ----- Selection complete. 15 rate(s) removed, 6 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: 11 1 430.5916 -0.02099751 0.970 NA 3965 4146 15864.44
## 2: 12 1 450.2123 -0.02149760 0.989 NA 4364 4545 16404.73
## 3: 13 1 445.1281 -0.02049892 0.958 NA 4764 4946 16944.69
## 4: 18 1 550.7561 -0.02309615 0.993 NA 6759 6940 19643.65
## 5: 19 1 495.5736 -0.01973802 0.973 NA 7158 7339 20184.10
## 6: 21 1 505.2340 -0.01919212 0.985 NA 7957 8139 21264.54
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 16109.20 96.954 91.923 -0.02099751 -2.091109e-04 -0.02078840 -0.02078840
## 2: 16649.58 97.474 91.924 -0.02149760 -1.915597e-04 -0.02130604 -0.02130604
## 3: 17190.57 97.363 92.009 -0.02049892 -1.740040e-04 -0.02032491 -0.02032491
## 4: 19888.62 96.860 91.235 -0.02309615 -8.635116e-05 -0.02300979 -0.02300979
## 5: 20429.20 96.685 92.166 -0.01973802 -6.879415e-05 -0.01966923 -0.01966923
## 6: 21510.13 97.200 92.232 -0.01919212 -3.369132e-05 -0.01915843 -0.01915843
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.2116708
## 2: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.2169415
## 3: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.2069516
## 4: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.2342895
## 5: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.2002753
## 6: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.1950742
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -294.2734 NA mgO2/hr/kg -294.2734
## 2: -301.6009 NA mgO2/hr/kg -301.6009
## 3: -287.7125 NA mgO2/hr/kg -287.7125
## 4: -325.7187 NA mgO2/hr/kg -325.7187
## 5: -278.4308 NA mgO2/hr/kg -278.4308
## 6: -271.2001 NA mgO2/hr/kg -271.2001
## -----------------------------------------
results <- data.frame(Clutch = Clutch,
Replicate =Replicate,
Male=Male,
Female=Female,
Population = Population,
Tank = Tank,
Mass = mass,
Chamber = chamber,
System = system1,
Volume = chamber_vol,
Date_tested = Date_tested,
Date_analysed =Date_analysed,
Swim = Swim,
Salinity = salinity,
Temperature = as.numeric(unique(firesting2$temperature)),
Resting_kg = mean(apoly_rmr$rate.output*-1),
Resting = mean(apoly_rmr$rate.output*-1)*mass,
rsqrest =mean(apoly_rmr$rsq))
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 8 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0007193 | ch1 | Asus | 0.04573 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 297.5473 | 0.2140257 | 0.9766 |
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.32 3.80
## -----------------------------------------
cycle1.start <- Cycle_1.mmr[1,1]
cycle1.end <- tail(Cycle_1.mmr, n=1)[1,1]
cycle1.start.row <- which(firesting2_mmr$TIME == cycle1.start); cycle1.start## Warning in which(firesting2_mmr$TIME == cycle1.start): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
## Warning in which(firesting2_mmr$TIME == cycle1.end): Incompatible methods
## ("Ops.difftime", "Ops.data.frame") for "=="
cycle1_data <- firesting2_mmr |>
subset_data(from = cycle1.start.row,
to = cycle1.end.row,
by = "row") ## subset_data: Multi-column dataset detected in input!
## subset_data is generally intended to subset data already passed through inspect(), or 2-column data frames where time and oxygen are in columns 1 and 2 respectively.
## Subsetting will proceed anyway based on this assumption, but please ensure you understand what you are doing.
## inspect: Applying column default of 'time = 1'
## inspect: Applying column default of 'oxygen = 2'
## Warning: inspect: Time values are not evenly-spaced (numerically).
## inspect: Data issues detected. For more information use print().
##
## # print.inspect # -----------------------
## dTIME ch1
## numeric pass pass
## Inf/-Inf pass pass
## NA/NaN pass pass
## sequential pass -
## duplicated pass -
## evenly-spaced WARN -
##
## Uneven Time data locations (first 20 shown) in column: dTIME
## [1] 2 3 4 5 6 7 8 10 11 12 13 14 16 17 18 19 20 21 22 23
## Minimum and Maximum intervals in uneven Time data:
## [1] 1.33 1.62
## -----------------------------------------
## Warning: auto_rate: Multi-column dataset detected in input. Selecting first two columns by default.
## If these are not the intended data, inspect() or subset the data frame columns appropriately before running auto_rate()
##
## # summary.auto_rate # -------------------
##
## === Summary of Results by Highest Rate ===
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 685.2312 -0.06806541 0.9808097 NA 8 52 8620.70
## 2: NA 2 686.0168 -0.06797983 0.9971499 NA 113 157 8762.89
## 3: NA 3 685.6731 -0.06794116 0.9971587 NA 111 155 8760.21
## 4: NA 4 684.0305 -0.06792563 0.9803489 NA 9 53 8622.08
## 5: NA 5 685.5032 -0.06792146 0.9971372 NA 112 156 8761.55
## ---
## 174: NA 174 523.3655 -0.04941969 0.9896396 NA 75 119 8711.53
## 175: NA 175 521.7069 -0.04922956 0.9899413 NA 74 118 8710.17
## 176: NA 176 521.4589 -0.04919906 0.9896731 NA 71 115 8706.14
## 177: NA 177 521.3703 -0.04919058 0.9900235 NA 73 117 8708.81
## 178: NA 178 520.4397 -0.04908352 0.9903009 NA 72 116 8707.48
## endtime oxy endoxy rate
## 1: 8680.70 98.293 94.533 -0.06806541
## 2: 8822.89 90.279 86.235 -0.06797983
## 3: 8820.21 90.392 86.384 -0.06794116
## 4: 8682.08 98.363 94.516 -0.06792563
## 5: 8821.55 90.349 86.406 -0.06792146
## ---
## 174: 8771.53 92.926 89.765 -0.04941969
## 175: 8770.17 92.928 89.858 -0.04922956
## 176: 8766.14 93.353 90.031 -0.04919906
## 177: 8768.81 93.046 89.896 -0.04919058
## 178: 8767.48 93.119 89.910 -0.04908352
##
## Regressions : 178 | Results : 178 | Method : highest | Roll width : 60 | Roll type : time
## -----------------------------------------
## adjust_rate: Rate adjustments applied using "mean" method.
##
## # print.adjust_rate # -------------------
## NOTE: Consider the sign of the adjustment value when adjusting the rate.
##
## Adjustment was applied using the 'mean' method.
##
## Rank 1 of 178 adjusted rate(s):
## Rate : -0.06806541
## Adjustment : -0.0004814342
## Adjusted Rate : -0.06758398
##
## To see other results use 'pos' input.
## To see full results use summary().
## -----------------------------------------
mmr_adj2 <- mmr_adj |>
convert_rate(oxy.unit = "%Air",
time.unit = "secs",
output.unit = "mg/h/kg",
volume = chamber_vol,
mass = mass,
S = salinity,
t = as.numeric(unique(firesting2$temperature)),
P = 1.013253)## convert_rate: Object of class 'adjust_rate' detected. Converting all adjusted rates in '$rate.adjusted'.
mmr_final <- mmr_adj2 |>
select_rate(method = "rsq", n=c(0.93,1)) |>
select_rate(method = "highest", n=1) |>
plot(type="full") |>
summary(export=TRUE)## select_rate: Selecting rates with rsq values between 0.93 and 1...
## ----- Selection complete. 0 rate(s) removed, 178 rate(s) remaining -----
## select_rate: Selecting highest 1 *absolute* rate values...
## ----- Selection complete. 177 rate(s) removed, 1 rate(s) remaining -----
##
## # plot.convert_rate # -------------------
## plot.convert_rate: Plotting all rate(s)...
## -----------------------------------------
##
## # summary.convert_rate # ----------------
## Summary of all converted rates:
##
## rep rank intercept_b0 slope_b1 rsq density row endrow time
## 1: NA 1 685.2312 -0.06806541 0.9808097 NA 8 52 8620.7
## endtime oxy endoxy rate adjustment rate.adjusted rate.input
## 1: 8680.7 98.293 94.533 -0.06806541 -0.0004814342 -0.06758398 -0.06758398
## oxy.unit time.unit volume mass area S t P rate.abs
## 1: %Air sec 0.04573 0.0007193 NA 36 30 1.013253 -0.6881511
## rate.m.spec rate.a.spec output.unit rate.output
## 1: -956.6955 NA mgO2/hr/kg -956.6955
## -----------------------------------------
results <- results |>
mutate(Max_kg = mmr_final$rate.output*-1,
Max = (mmr_final$rate.output*-1)*mass,
rsqmax =mmr_final$rsq,
AAS_kg = Max_kg - Resting_kg,
AAS = Max - Resting,
Notes=Notes,
True_resting="")
knitr::kable(results, "simple") | Clutch | Replicate | Male | Female | Population | Tank | Mass | Chamber | System | Volume | Date_tested | Date_analysed | Swim | Salinity | Temperature | Resting_kg | Resting | rsqrest | Max_kg | Max | rsqmax | AAS_kg | AAS | Notes | True_resting |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 124 | 8 | CSUD312 | CSUD304 | Sudbury reef | 167 | 0.0007193 | ch1 | Asus | 0.04573 | 2023-06-18 | 2024-06-08 | good/good | 36 | 30 | 297.5473 | 0.2140257 | 0.9766 | 956.6955 | 0.6881511 | 0.9808097 | 659.1482 | 0.4741253 | Chamber2 was mistakenly in place of chamber1 | |
| ### Expor | ting data |
## Rows: 32 Columns: 25
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (9): Male, Female, Population, Chamber, System, Date_tested, Swim, Note...
## dbl (16): Clutch, Replicate, Tank, Mass, Volume, Date_analysed, Salinity, Te...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.